<template>
    <div class="app-container">
      <!--  -->
      <el-table :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">
        <!-- <el-table-column type="selection" width="32"></el-table-column> -->
        <el-table-column prop="totalWorkId" fixed label="序号" width="51" />
        <el-table-column prop="totalWorkYear" fixed label="年度" width="71" />
        <el-table-column prop="username" fixed label="姓名" width="70" />
        <el-table-column prop="quotaStandard" label="定额标准" width="53" />
        <el-table-column prop="projectScore" label="科研项目分值" width="72" />
        <el-table-column prop="academicWorkScore" label="学术著作分值" width="72" />
        <el-table-column prop="decisionConsultingScore" label="决策咨询类分值" width="77" />
        <el-table-column prop="creativeAchievementScore" label="创作成果类分值" width="77" />
        <el-table-column prop="intellectualPropertyScore" label="知识产权类分值" width="77" />
        <el-table-column prop="transferScore" label="成果转化类分值" width="77" />
        <el-table-column prop="awardScore" label="科研奖项分值" width="64" />
        <el-table-column prop="networkCultureScore" label="网络文化类分值" width="77" />
        <el-table-column prop="paperScore" label="学术论文分值" width="64" />
        <el-table-column prop="activityScore" label="科技活动分值" width="64" />
        <el-table-column prop="platformScore" label="重要科研平台分值" width="77" />
        <el-table-column prop="totalScore" label="总分" width="55" />
        <el-table-column prop="remarks" label="备注"/>
      </el-table>
     
  <!-- 分页组件 -->
  <Pagination v-model="queryParams" :total="total" @change="handleChange" />
      <el-footer>
  
      </el-footer>
    </div>
  </template>
  
  <script setup>
  import { ref, onMounted, reactive } from 'vue';
  import { totalUserList } from "@/api/totalWork";
  import { ElMessage, ElMessageBox } from 'element-plus';
  import Pagination from '@/components/Pagination/index.vue';
  
  const tableData = ref([]); // 初始化为响应式数组
  const title = ref("");
  const open = ref(false);
  //处理选中行
  const selectedRow = ref(null);
  
  // 定义查询参数
  const queryParams = ref({
    currentPage: 1,
    pageSize: 10,
  });
  const total = ref(0);

  // 查询方法
  async function handleQuery() {
    try {
      const response = await totalUserList({
        currentPage: queryParams.value.currentPage, // 分页从1开始
        pageSize: queryParams.value.pageSize
      });
      tableData.value = response.data; // 更新表格数据
      total.value = response.total; // 总条目数
      console.log('查询结果:', response.data);
    } catch (error) {
      console.error('查询失败:', error);
    }
  }
  
  
  
  const handleChange = (newPage, newPageSize) => {
      queryParams.value.currentPage = newPage;
      queryParams.value.pageSize = newPageSize;
      handleQuery();
  };
  
  // 页面加载时自动查询一次
  onMounted(() => {
    handleQuery();
  });
  
  </script>
  
  <style scoped>
  .el-input__inner {
    margin-left: 2px;
  }
  </style>